package com.song.provider.controller;

import com.song.provider.pojo.Book;
import com.song.provider.service.BookService;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author 宋伟宁
 * @Date 2024/1/9
 * @Version 1.0
 **/
@RestController
@RequestMapping("/provider")
public class BookController {

    @Resource
    private BookService bookService;
    @Value("${server.port}")
    private String port;

    @GetMapping("/")
    public List<Book> getBookList(){
        return bookService.books();
    }

    @GetMapping("/{id}")
    public Book findById(@PathVariable("id") long id){
        return this.bookService.getBookById(id);
    }

}
